package com.ma.advanced;

import com.ma.logarithm.randomArray;
import com.ma.sort.sortTest;

public class dichotomyTest {

    /**
     * 利用对数器测试在有序数组中查找某数
     * @param testTime
     * @param maxSize
     * @param Maxvalue
     */
    public static void dichotomyTestToLogarithm(int testTime, int maxSize, int Maxvalue){
        int n=0;
        for (int i = 0; i < testTime; i++) {
            int[] arr= randomArray.getRandomArray(maxSize,Maxvalue);
            sortTest.comparator(arr);
            int num= arr[(int) ((arr.length)*Math.random())];
            if(!(dichotomy.exist(arr,num))){
                n++;
            }

        }
        if(n>0){
            System.out.println("共有"+n+"个用例失败");
        }else {
            System.out.println("恭喜，测试成功!");
        }
    }

}
